#include "Core/Model.h"
#include "Debug/Exceptions.h"

namespace blue {

Model::Model(const dataf &pos, const dataf &tex, const dataf &nor, const datai &indices, const char *name) :
IResource(name), _pos(pos), _tex(tex), _nor(nor), _indices(indices)
{
}

Model::~Model()
{
    if(_pos.data) delete[] _pos.data;
    if(_tex.data) delete[] _tex.data;
    if(_nor.data) delete[] _nor.data;
    if(_indices.data) delete[] _indices.data;
}

const dataf &Model::getBuffer(dataf_t type) const
{
    switch(type)
    {
        case DATAF_POSITION: return _pos; break;
        case DATAF_TEXTURE: return _tex; break;
        case DATAF_NORMAL: return _nor; break;
        default: throw BadType("dataf_t type unknown.");
    }
}

const datai &Model::getIndexBuffer() const
{
    return _indices;
}

}

